<?php


Route::prefix('admin')->group(function() {

    Route::get('/', 'AdminController@index')->name('admin.index')->middleware('admin.auth:admin');

    Route::get('/login','LoginController@showLoginForm')->name('admin.loginForm');;
    Route::post('/login','LoginController@login')->name('admin.login');

    /*
    |--------------------------------------------------------------------------
    | 退出、更改密码
    |--------------------------------------------------------------------------
    */
    Route::group(['prefix'=>'user'],function (){
        //退出
        Route::get('logout','UserController@logout')->name('admin.user.logout')->middleware('auth');
        //更改密码
        Route::get('change_my_password_form','UserController@changeMyPasswordForm')->name('admin.user.changeMyPasswordForm')->middleware('auth');
        Route::post('change_my_password','UserController@changeMyPassword')->name('admin.user.changeMyPassword')->middleware('auth');
    });

    /*
    |--------------------------------------------------------------------------
    | 系统管理
    |--------------------------------------------------------------------------
    */
    Route::group(['middleware'=>['admin.auth:admin','permission:system']],function (){

        //用户管理
        Route::group(['prefix'=>'user','middleware'=>['permission:system.user']],function (){
            //退出
            Route::get('logout','LoginController@logout')->name('admin.user.logout');
            //更改密码
            Route::get('change_my_password_form','UserController@changeMyPasswordForm')->name('admin.user.changeMyPasswordForm')->middleware('auth');
            Route::post('change_my_password','UserController@changeMyPassword')->name('admin.user.changeMyPassword')->middleware('auth');

            Route::get('/','UserController@index')->name('admin.user');
            Route::get('/data','UserController@data')->name('admin.user.data');
            //添加
            Route::get('/create','UserController@create')->name('admin.user.create')->middleware('permission:system.user.create');
            Route::post('/store','UserController@store')->name('admin.user.store')->middleware('permission:system.user.create');
            //编辑
            Route::get('/{id}/edit','UserController@edit')->name('admin.user.edit')->middleware('permission:system.user.edit');
            Route::put('/{id}/update','UserController@update')->name('admin.user.update')->middleware('permission:system.user.edit');
            //删除
            Route::delete('/destroy','UserController@destroy')->name('admin.user.destroy')->middleware('permission:system.user.destroy');
            //分配角色
            Route::get('/{id}/role','UserController@role')->name('admin.user.role')->middleware('permission:system.user.role');
            Route::put('/{id}/assignRole','UserController@assignRole')->name('admin.user.assignRole')->middleware('permission:system.user.role');
            //分配权限
            Route::get('/{id}/permission','UserController@permission')->name('admin.user.permission')->middleware('permission:system.user.permission');
            Route::put('/{id}/assignPermission','UserController@assignPermission')->name('admin.user.assignPermission')->middleware('permission:system.user.permission');

        });

        //角色管理
        Route::group(['prefix'=>'role','middleware'=>'permission:system.role'],function (){
            Route::get('/','RoleController@index')->name('admin.role');
            Route::get('/data','RoleController@data')->name('admin.role.data');
            //添加
            Route::get('/create','RoleController@create')->name('admin.role.create')->middleware('permission:system.role.create');
            Route::post('/store','RoleController@store')->name('admin.role.store')->middleware('permission:system.role.create');
            //编辑
            Route::get('/{id}/edit','RoleController@edit')->name('admin.role.edit')->middleware('permission:system.role.edit');
            Route::put('/{id}/update','RoleController@update')->name('admin.role.update')->middleware('permission:system.role.edit');
            //删除
            Route::delete('/destroy','RoleController@destroy')->name('admin.role.destroy')->middleware('permission:system.role.destroy');
            //分配权限
            Route::get('/{id}/permission','RoleController@permission')->name('admin.role.permission')->middleware('permission:system.role.permission');
            Route::put('/{id}/assignPermission','RoleController@assignPermission')->name('admin.role.assignPermission')->middleware('permission:system.role.permission');
        });

        //权限管理
        Route::group(['prefix'=>'permission','middleware'=>'permission:system.permission'],function (){
            Route::get('/','PermissionController@index')->name('admin.permission');
            Route::get('/data','PermissionController@data')->name('admin.permission.data');
            //添加
            Route::get('/create','PermissionController@create')->name('admin.permission.create')->middleware('permission:system.permission.create');
            Route::post('/store','PermissionController@store')->name('admin.permission.store')->middleware('permission:system.permission.create');
            //编辑
            Route::get('/{id}/edit','PermissionController@edit')->name('admin.permission.edit')->middleware('permission:system.permission.edit');
            Route::put('/{id}/update','PermissionController@update')->name('admin.permission.update')->middleware('permission:system.permission.edit');
            //删除
            Route::delete('/destroy','PermissionController@destroy')->name('admin.permission.destroy')->middleware('permission:system.permission.destroy');
        });

        //配置组
        Route::group(['prefix'=>'config_group','middleware'=>'permission:system.config_group'],function (){

            Route::get('/','ConfigGroupController@index')->name('admin.config_group');
            Route::get('/data','ConfigGroupController@data')->name('admin.config_group.data');
            //添加
            Route::get('/create','ConfigGroupController@create')->name('admin.config_group.create')->middleware('permission:system.config_group.create');
            Route::post('/store','ConfigGroupController@store')->name('admin.config_group.store')->middleware('permission:system.config_group.create');
            //编辑
            Route::get('/{id}/edit','ConfigGroupController@edit')->name('admin.config_group.edit')->middleware('permission:system.config_group.edit');
            Route::put('/{id}/update','ConfigGroupController@update')->name('admin.config_group.update')->middleware('permission:system.config_group.edit');
            //删除
            Route::delete('/destroy','ConfigGroupController@destroy')->name('admin.config_group.destroy')->middleware('permission:system.config_group.destroy');
        });

        //配置项
        Route::group(['prefix'=>'configuration','middleware'=>'permission:system.configuration'],function (){
            Route::get('/','ConfigurationController@index')->name('admin.configuration');
            //添加
            Route::get('/create','ConfigurationController@create')->name('admin.configuration.create')->middleware('permission:system.configuration.create');
            Route::post('/store','ConfigurationController@store')->name('admin.configuration.store')->middleware('permission:system.configuration.create');
            //编辑
            Route::put('/update','ConfigurationController@update')->name('admin.configuration.update')->middleware('permission:system.configuration.edit');
            //删除
            Route::delete('/destroy','ConfigurationController@destroy')->name('admin.configuration.destroy')->middleware('permission:system.configuration.destroy');
        });

    });

});


